import React from 'react';
import CssBaseline from '@material-ui/core/CssBaseline';
import Link from '@material-ui/core/Link';
import Typography from '@material-ui/core/Typography';
import { makeStyles } from '@material-ui/core/styles';
import Container from '@material-ui/core/Container';
import Box from '@material-ui/core/Box';
import { Button, Card, CardContent } from '@material-ui/core';

function Copyright() {
  return (
    <Typography variant="body2" color="textSecondary" align="center">
      {'Copyright © '}
      <Link color="inherit" href="https://github.com/nullptrjzz">
        nullptrjzz
      </Link>{' '}
      {new Date().getFullYear()}
      {'.'}
    </Typography>
  );
}

const useStyles = makeStyles((theme) => ({
  card: {
    margin: '48px',
    padding: '16px'
  },
  button: {
    marginTop: '16px'
  }
}));

const goBack = () => {
  window.history.back()
}

export default function Message() {
  const classes = useStyles();
  const msg = document.getElementById('msg').innerHTML;

  return (
    <Container maxWidth="sm">
      <CssBaseline />
      <Card className={classes.card}>
        <CardContent>
          <Typography variant="h4">{msg}</Typography>
          <Button
            className={classes.button}
            type="button"
            fullWidth
            variant="contained"
            color="primary"
            onClick={goBack}>返回上一页</Button>
        </CardContent>
      </Card>
      <Box mt={8}>
        <Copyright />
      </Box>
    </Container>
  );
}